<template>
  <el-cascader
    size="mini"
    :value="value"
    :options="options"
    separator="-"
    :props="{value:'id',label:'name'}"
    @change="handleChange"
  />

</template>

<script>
// 引用获取部门api
import { getDepartment } from '@/api/department.js'
// 引用处理数据函数
import { ProcessingData } from '@/utils/index'
export default {
  props: {
    value: {
      type: Number,
      default: null
    }
  },
  data() {
    return {
      options: []
    }
  },
  created() {
    this.getDepartment()
  },
  methods: {
    async getDepartment() {
      const result = await getDepartment()
      // console.log(result.data)
      // console.log(ProcessingData(result.data, 0))
      this.options = ProcessingData(result.data, 0)
    },
    handleChange(value) {
      // console.dir(value)
      this.$emit('upvalue', value[value.length - 1])
    }

  }
}
</script>

<style>

</style>
